package com.foreknow.demo12;

public class ManagerImpl implements Manager {
    private Employee[] employees; //定义数组容器用来保存员工对象
    private int count;
    public ManagerImpl() {
        employees = new Employee[3];
    }
    @Override
    public void addEmployee(Employee employee) {
        if(employees!=null) {
            if(count < 3) {
                employees[count] = employee; //将员工对象保存到数组中
                count++;
                System.out.println("添加成功");
            }else {
                System.out.println("添加失败");
            }
        }
    }

    @Override
    public Employee getQueryById(int eid) {
        //        for遍历数组 {
        //            判断数组中的某个元素的eid是否与用户输入的eid相等
        //        }
        Employee emp = null;
        for(int i = 0;i<employees.length;i++) {
            if (employees[i] != null) {
                if(employees[i].getEid() == eid) {  //employees[i].getEid()表示获取某个员工的编号
                    emp = employees[i];
                }
            }
        }
        return emp;
    }

    @Override
    public Employee[] getQueryAll() {
        return new Employee[0];
    }

    @Override
    public Employee updateEmployee(Employee employee) {
        return null;
    }
}
